package com.homedo.async.mysql.support.prepare;

import com.homedo.async.mysql.support.dml.DMLEnum;
import com.homedo.async.mysql.support.meta.EntityMetaData;
import com.homedo.async.mysql.support.prepare.delete.RecordId2Sql4Delete;
import com.homedo.async.mysql.support.prepare.select.RecordId2Sql4Select;
import lombok.Data;

/**
 * @author jgshun
 * @date 2020/3/5 1:56 PM
 */
@Data
public class PrepareRecordId2Sql<T, ID> {

    private Iterable<ID> ids;
    private EntityMetaData<T> entityMetaData;
    private DMLEnum dml;

    public PrepareRecordId2Sql() {
    }

    public PrepareRecordId2Sql(EntityMetaData<T> entityMetaData, DMLEnum dml, Iterable<ID> ids) {
        this.entityMetaData = entityMetaData;
        this.dml = dml;
        this.ids = ids;
    }

    public Object[] prepare() {
        if (this.dml == DMLEnum.SELECT) {
            return RecordId2Sql4Select.prepare(this.entityMetaData, ids);
        } else if (this.dml == DMLEnum.DELETE) {
            return RecordId2Sql4Delete.prepare(this.entityMetaData, ids);
        } else {
            //TODO
        }

        return null;
    }

}

